package com.checkcode.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		//编码设置
		resp.setContentType("text/html;charset=UTF-8");
		//获取session中保存的验证码的值
		String code = (String) req.getSession().getAttribute("code");
		//获取输入框的值
		String checkcode =  req.getParameter("checkcode");
		PrintWriter out = resp.getWriter();
		//判断是否正确
		if (code.equals(checkcode.toUpperCase())) {
			out.println("验证码正确");
		}else {
			out.println("验证码错误");
		}
		out.write("<br/><a href='checkcode.jsp'>返回</a>");
	}
}
